<template>
  <div class="box5">
    <div class="title">
      <p>未来7天游客数量趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
let charts = ref()

onMounted(() => {
  let myCharts = echarts.init(charts.value)
  myCharts.setOption({
    title: {
      text: '访问量',
      textStyle: {
        color: 'white',
      },
      top: '10%',
      left: '5%',
    },
    xAxis: {
      type: 'category',
      //两侧不留白
      boundaryGap: false,
      //不要分割线
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: 'white',
        },
      },
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
    },
    yAxis: {
      //轴线设置
      axisLine: {
        show: true,
        lineStyle: {
          color: 'white',
        },
      },
      //不要分割线
      splitLine: {
        show: false,
      },
      //刻度
      axitTick: {
        show: true,
      },
    },
    grid: {
      left: 30,
      right: 10,
      top: 5,
      bottom: 40,
    },
    series: [
      {
        type: 'line',
        data: [120, 180, 489, 203, 699, 300, 700],
        //平滑曲线
        smooth: true,
        //设置填充区域颜色
        areaStyle: {
          color: {
            tyle: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'orange',
              },
              {
                offset: 1,
                color: 'rgb(1,52,129)',
              },
            ],
            global: false,
          },
        },
      },
      {},
    ],
  })
})
</script>

<style scoped lang="scss">
.box5 {
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  margin: 5px 0px;
  .title {
    margin-top: 10px;
    margin-left: 20px;
    color: white;
    font-size: 18px;
  }

  .charts {
    width: 100%;
    height: calc(100% - 40px);
  }
}
</style>
